from concurrent.futures import ThreadPoolExecutor
import mss
import pygetwindow
import torch
from ultralytics import YOLO

import Config
from fight_card import FightCard
from repair_out import RepairOut
from switch import Switch
from tools import WindowUtil, ColorUtil

# 游戏窗口区域
# left表示距离屏幕左边多少像素
# top表示距离屏幕顶部多少像素
# width表示截图的宽度是多少像素
# height表示截图的高度是多少像素
position_window = {"left": 0, "top": 0, "width": 1000, "height": 570}
position_grab = {"left": 0, "top": 0, "width": 960, "height": 570}

# =====================加载AI模型==============================
# model = YOLO('model/洛兰.pt', task='detect')
# # 检查是否有可用的GPU
# use_cuda = torch.cuda.is_available()
# device = torch.device("cuda:0" if use_cuda else "cpu")
# print(f"当前设备：{device}")
# # 将模型加载到设备上
# model.to(device)
# print(f"AI模型加载中。。。")

# =====================窗口设置==============================
with mss.mss() as sct:
    windows_ = pygetwindow.getWindowsWithTitle("雷电模拟器")[0]
    print(windows_.width, windows_.height)

    pos_dic = dict(position_window)
    windows_.resizeTo(pos_dic.get("width"), pos_dic.get("height"))
    windows_.moveTo(pos_dic.get("left"), pos_dic.get("top"))
    windows_.activate()

window = WindowUtil.grab_screen(position_grab)
locs = [(107, 79), (107, 80), (107, 81), (107, 82)]
colors = [(194, 0, 10),(201, 0, 10),(199, 0, 11),(198, 0, 12),]
flag = ColorUtil.check_colors_similar(ColorUtil.cv2pil(window), locs, colors)
print(flag)
